// router.js
import { createRouter, createWebHistory } from "vue-router";
import Layout from "../layout/index.vue";
const routes = [
  {
    path: "/",
    component: Layout,
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "Home",
        component: () => import("../views/home/index.vue"),
      },
    ],
  },
  {
    path: "/element",
    component: Layout,
    redirect: "/element/tableGantt",
    children: [
      {
        path: "input",
        name: "input",
        component: () => import("../views/element/input.vue"),
      },
      {
        path: "tableGantt",
        name: "TableGantt",
        component: () => import("../views/element/tableGantt.vue"),
      },
      {
        path: "table",
        name: "table",
        component: () => import("../views/element/table.vue"),
      },
    ],
  },
  {
    path: "/fbx",
    component: Layout,
    children: [
      {
        path: "index",
        name: "fbx",
        component: () => import("../views/fbx/index.vue"),
      },
    ],
  },
  {
    path: "/product",
    name: "Product",
    redirect: "/product/list",
    children: [
      {
        path: "list",
        name: "List",
        component: () => import("../views/product/list.vue"),
      },
      {
        path: "detail/:id/:b",
        name: "Detail",
        component: () => import("../views/product/detail.vue"),
      },
    ],
  },
  {
    path: "/workflow",
    component: Layout,
    children: [
      {
        path: "index",
        name: "Index",
        component: () => import("../views/workflow/index.vue"),
      },
    ],
  },
  {
    path: "/gantt",
    component: Layout,
    redirect: "/gantt/index",
    children: [
      {
        path: "index",
        name: "Gantt",
        component: () => import("../views/gantt/index.vue"),
      },
    ],
  },

  {
    path: "/jsFunction",
    component: Layout,
    redirect: "/jsFunction/roll",
    children: [
      {
        path: "roll",
        name: "Roll",
        component: () => import("../views/jsFunction/roll.vue"),
      },
    ],
  },
];
const router = createRouter({
  history: createWebHistory(), // 使用 HTML5 History 模式
  routes,
});

router.beforeEach((to, from, next) => {
  console.log(to, from, "路由跳转");
  // 验证权限
  next();
});
export default router;
